var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("AssetsMap"),
    c = e("BundleNames"),
    l = e("ConfigGameData"),
    d = e("GameData"),
    u = e("TaskData"),
    p = e("BaseControl"),
    h = e("GameModuleView"),
    f = cc._decorator.ccclass,
    _ = (function (e) {
        function t() {
            return (null !== e && e.apply(this, arguments)) || this;
        }
        return (
            a(t, e),
            (t.prototype.init = function () {
                e.prototype.init.call(this),
                    (h.default.Insance._layer_snake.playerControl = this),
                    (h.default.Insance._view_killList.label_userKill_num = 0);
            }),
            (t.prototype.update = function () {
                if (d.default.instance.gameState == d.GameState.play && h.default.Insance._layer_food.portal) {
                    var e = h.default.Insance.viewModel.tip_arrow,
                        t = h.default.Insance._layer_food.portal.position,
                        o = cc.v2(t.x - this._snake.head_pos.x, t.y - this._snake.head_pos.y).normalize(),
                        n = cc.v3(this._snake.head_pos.x + 150 * o.x, this._snake.head_pos.y + 150 * o.y, 0);
                    (e.position = n),
                        (e.angle = l.default.vectorToAngle(o)),
                        this._snake.head_pos.sub(t).mag() < 150 &&
                            ((d.default.instance.gameState = d.GameState.stop), this.intoTransfer());
                }
            }),
            (t.prototype.getSnakesParam = function () {
                for (var e = [], t = h.default.Insance._layer_snake.snakeList, o = 0; o < t.length; o++) {
                    var n = t[o];
                    if (n.snakeName != d.default.instance.UserName) {
                        var i = {name: n.snakeName, score: n.score};
                        e.push(i);
                    }
                }
                return {aiData: e, score: this._snake.score};
            }),
            (t.prototype.intoTransfer = function () {
                var e = this.getSnakesParam().aiData,
                    t = {
                        isStoreHose: !0,
                        isFirstKill: h.default.Insance._view_killList.onceKill,
                        killNum: h.default.Insance._view_killList._label_userKill_num,
                        score: this._snake.score,
                        aiData: e,
                        temp: 1
                    };
                game.UIManager.instance.replaceModuleView(
                    c.default.Game,
                    s.default.GameBundle.prefabs.assetsList.GameModuleView,
                    t
                );
            }),
            (t.prototype.portalBack = function () {
                this._snake.resetSnakePos(),
                    this._snake.initIgnore(),
                    (d.default.instance.gameState = d.GameState.play);
            }),
            (t.prototype.eatFood = function (e) {
                u.default.instance.collectFoodData(e);
            }),
            (t.prototype.refreshView_Magnet = function () {
                h.default.Insance.refreshMagnetTimer(
                    this._snake._snakeIsProp_Magnet,
                    (10 - this._snake._prop_Magnet_Timer).toFixed(2)
                );
            }),
            (t.prototype.refreshView_Double = function () {
                h.default.Insance.refreshDoubleTimer(
                    this._snake._snakeIsProp_Magnet,
                    (10 - this._snake._prop_Magnet_Timer).toFixed(2)
                );
            }),
            (t.prototype.refreshView_Shield = function () {
                h.default.Insance.refreshPorp_Shield(this._snake.porp_shield_index);
            }),
            (t.prototype.refreshView_Missile = function () {
                h.default.Insance.refreshPorp_Missile(this._snake._MissilesNumber);
            }),
            (t.prototype.refreshCameraPos = function (e) {
                h.default.Insance.refreshCameraPos(e, this._snake.snake_scale);
            }),
            r([f], t)
        );
    })(p.default);
i.default = _;
